#pragma once
#include <list>
#include <map>
using std::multimap;
using std::pair;
using std::list;
#include "NEvent.h"
#include "IListener.h"
class CEventSystem
{
private:
	multimap<EVENTID, IListener*>m_ClientDatabase;
	list<CNEvent>m_CurrentEvents;
	void DispatchEvent(CNEvent* pEvent);
	bool AlreadyRegistered(EVENTID eventID, IListener* pClient);
	CEventSystem() {}
	CEventSystem(const CEventSystem&);
	CEventSystem& operator=(const CEventSystem&);
	~CEventSystem() {}
public:
	static CEventSystem* GetInstance(void)
	{
		static CEventSystem instance;
		return &instance;
	}
	void RegisterClient(EVENTID eventID, IListener* pClient);
	void UnregisterClient(EVENTID eventID, IListener* pClient);
	void UnregisterClientAll(IListener* pClient);
	bool HasEventTriggered( EVENTID eventID );
	void SendEvent(EVENTID eventID, void* pData = NULL);
	void SendUniqueEvent( EVENTID eventID, void* pData = NULL );
	void ProcessEvents(void);
	void ClearEvents(void);
	void ShutdownEventSystem(void);
};

